/**
 * Copyright (C) 2018 - 2020 https://github.com/LeeYan9
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bifrost.entity;

import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Lee
 * Create Class on 2018/8/9
 * @com.bifrost.entity
 * @wechat-mall
 */
@Entity
@Data
@Table(name = "PLAN")
public class Plan extends BaseEntity implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PLAN_ID", unique = true, nullable = false)
    private Long planId;

    @Column(name = "ACTIVE_START_TIME", columnDefinition = "datetime DEFAULT NULL COMMENT '活动开始时间'")
    @Temporal(value = TemporalType.TIMESTAMP)
    private Date activeStartTime;
    @Column(name = "ACTIVE_END_TIME", columnDefinition = "datetime DEFAULT NULL COMMENT '活动结束时间'")
    @Temporal(value = TemporalType.TIMESTAMP)
    private Date activeEndTime;

    @Column(name = "IS_ARCHIVED", columnDefinition = "bit(1) DEFAULT NULL COMMENT '是否删除'")
    private Boolean archived = Boolean.FALSE;

    @Column(name = "DESCRIPTION" , columnDefinition = "varchar(255) DEFAULT NULL COMMENT '活动详情'")
    private String description;

    @Enumerated(value = EnumType.STRING)
    @Column(name = "PLAN_STATUS")
    private PlanStatus status = PlanStatus.NEW;

    @Column(name = "TITLE" ,columnDefinition = "varchar(128) DEFAULT NULL COMMENT '活动标题'")
    private String title;

    @Column(name = "MERCHANT_ID" ,columnDefinition = "bigint(20) DEFAULT NULL COMMENT '门店'" ,nullable = false)
    private Long storeId;

    @Column(name = "URL" ,columnDefinition = "varchar(128) DEFAULT NULL COMMENT '活动展示图片'")
    private String url;


    @Enumerated(value = EnumType.STRING)
    @Column(name = "PLAN_TYPE", nullable = false)
    private PlanType planType = com.bifrost.entity.PlanType.TRYOUT;

    @OneToMany(fetch = FetchType.LAZY , mappedBy = "plan")
    private List<PlanItem> planItems = new ArrayList<>();

}
